let loginModule=( function(){

    let $username=$('.userName'),
        $userpass=$('.userPass'),
        $sumbit=$('.submit')

    function handle(){
        $sumbit.click(async function(){
            let account=$username.val().trim(),
                password=$userpass.val().trim()
            
            if(account==''|| password==''){
                alert('账号或密码不能为空哦!')
                return
            }

            password=md5(password)

            let res=await axios.post('/user/login',{
                account,
                password
            })
            
            if(parseInt(res.code)==0){
                alert('登录成功，即将跳转到首页')
                window.location.href='index.html'
                return
            }
            //错误情况
            alert('您输入的账号或密码有误！')
        })
    }
    return {
        init(){
            handle()
        }
    }
})()
loginModule.init()